# 矩阵置零

class Solution:

    def setZeros(self, matrix: list[list[int]]):
        m = len(matrix)
        n = len(matrix[0])
        temp_i = set()
        temp_j = set()
        for i in range(m):
            for j in range(n):
                if matrix[i][j] == 0:
                    temp_i.add(i)
                    temp_j.add(j)

        for it in temp_i:
            matrix[it] = [0] * n
        for it in temp_j:
            for k in range(m):
                matrix[k][it] = 0
            # [matrix[k][it] = 0 for k in range(m)]

if __name__ == "__main__":

    matrix = [[1,1,1],[1,0,1],[1,1,1]]
    sol = Solution()
    sol.setZeros(matrix)

    print(matrix)
